package io.renren.modules.generator.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.generator.dao.StudentDao;
import io.renren.modules.generator.entity.StudentEntity;
import io.renren.modules.generator.service.StudentService;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("StudentService")
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        EntityWrapper<StudentEntity> entityWrapper = new EntityWrapper<>();
        String key = (String)params.get("key");
        if(key != null){
            entityWrapper.like("username",key);
        }
        Page<StudentEntity> page = this.selectPage(
                new Query<StudentEntity>(params).getPage(),entityWrapper
        );
        return new PageUtils(page);
    }
}
